/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kotionokyurievna.gmail.com.threadjoinvolatile.logic;

/**
 *
 * @author Kateryna_Reznik
 */
public class OneByOneArrayCreator implements ArrayCreator{

    /**
     * Creates array of integer values
     * @param min - min value of array
     * @param step - difference between a[i] and a[i-1]
     * @param length - length of array, length > 0
     * @return created Array
     * @throws IllegalArgumentException - throws than length <= 0,  
     *                      
     */
    @Override
    public int[] create(int min, int step, int length) throws IllegalArgumentException{
        if (  length > 0 ){  
            int resultArray[] = new int[length];
            for ( int i = 0; i < length; i++){
                resultArray[i] = min + i * step;
            }
            return resultArray;
        }
        else{
            throw new IllegalArgumentException( "length must be > 0" );
        }
    }
    
    public String toString(){
        return getClass().getName();
    }
    
}
